<?php

declare(strict_types=1);

namespace app\validate;

use think\Validate;

class User extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'email' => 'require|email',
        'nickname' => 'length:2,20',
        'password' => 'require|length:6,20',
        'avatar' => 'url',
        'code' => 'length:6'

    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'email.require' => '邮箱不能为空',
        'email.email' => '邮箱格式不正确',
        'nickname.length' => '昵称长度必须在2-20个字符之间',
        'password.require' => '密码不能为空',
        'password.length' => '密码长度必须在6-20个字符之间',
        'avatar.url' => '头像必须是有效的URL地址',
        'code.length' => '验证码必须是6位数字'
    ];
}
